package GUI;


import BL.PendlerpauschaleDaten;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Tobias
 */
public class PendlerpauschaleDLG extends javax.swing.JDialog {

    private PendlerpauschaleDaten data; 
    /**
     * Creates new form PendlerpauschaleDLG
     */
    public PendlerpauschaleDLG(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        data = new PendlerpauschaleDaten();
        printValues();
    }
    
    private void printValues() {
        tf20kj.setText(String.format("%.2f", data.getKleinesPendlerpauschaleJahr()[0]));
        tf40kj.setText(String.format("%.2f", data.getKleinesPendlerpauschaleJahr()[1]));
        tf60kj.setText(String.format("%.2f", data.getKleinesPendlerpauschaleJahr()[2]));
        tf20km.setText(String.format("%.2f", data.getKleinesPendlerpauschaleMonat()[0]));
        tf40km.setText(String.format("%.2f", data.getKleinesPendlerpauschaleMonat()[1]));
        tf60km.setText(String.format("%.2f", data.getKleinesPendlerpauschaleMonat()[2]));
        
        tf2gj.setText(String.format("%.2f", data.getGrossesPendlerpauschaleJahr()[0]));
        tf20gj.setText(String.format("%.2f", data.getGrossesPendlerpauschaleJahr()[1]));
        tf40gj.setText(String.format("%.2f", data.getGrossesPendlerpauschaleJahr()[2]));
        tf60gj.setText(String.format("%.2f", data.getGrossesPendlerpauschaleJahr()[3]));
        tf2gm.setText(String.format("%.2f", data.getGrossesPendlerpauschaleMonat()[0]));
        tf20gm.setText(String.format("%.2f", data.getGrossesPendlerpauschaleMonat()[1]));
        tf40gm.setText(String.format("%.2f", data.getGrossesPendlerpauschaleMonat()[2]));
        tf60gm.setText(String.format("%.2f", data.getGrossesPendlerpauschaleMonat()[3]));
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        tf20kj = new javax.swing.JTextField();
        tf40kj = new javax.swing.JTextField();
        tf60kj = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        tf20km = new javax.swing.JTextField();
        tf40km = new javax.swing.JTextField();
        tf60km = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        tf2gj = new javax.swing.JTextField();
        tf20gj = new javax.swing.JTextField();
        tf40gj = new javax.swing.JTextField();
        tf60gj = new javax.swing.JTextField();
        jLabel31 = new javax.swing.JLabel();
        tf2gm = new javax.swing.JTextField();
        tf20gm = new javax.swing.JTextField();
        tf40gm = new javax.swing.JTextField();
        tf60gm = new javax.swing.JTextField();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        btUebernehmen = new javax.swing.JButton();
        btAbbrechen = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Pendlerpauschale");
        getContentPane().setLayout(new java.awt.GridLayout(10, 5));

        jLabel1.setBackground(new java.awt.Color(217, 186, 78));
        jLabel1.setFont(new java.awt.Font("NSimSun", 0, 18)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel1.setText("Kleines Pendlerpauschale");
        jLabel1.setOpaque(true);
        getContentPane().add(jLabel1);

        jLabel2.setBackground(new java.awt.Color(217, 186, 78));
        jLabel2.setOpaque(true);
        getContentPane().add(jLabel2);

        jLabel3.setBackground(new java.awt.Color(217, 186, 78));
        jLabel3.setOpaque(true);
        getContentPane().add(jLabel3);

        jLabel4.setBackground(new java.awt.Color(217, 186, 78));
        jLabel4.setOpaque(true);
        getContentPane().add(jLabel4);

        jLabel11.setBackground(new java.awt.Color(217, 186, 78));
        jLabel11.setOpaque(true);
        getContentPane().add(jLabel11);
        getContentPane().add(jLabel5);

        jLabel14.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel14.setText("ab 20 km");
        getContentPane().add(jLabel14);

        jLabel13.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel13.setText("über 40 km");
        getContentPane().add(jLabel13);

        jLabel12.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel12.setText("über 60 km");
        getContentPane().add(jLabel12);
        getContentPane().add(jLabel6);

        jLabel7.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel7.setText("jährlich ");
        jLabel7.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        getContentPane().add(jLabel7);

        tf20kj.setBackground(new java.awt.Color(217, 186, 78));
        tf20kj.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf20kj.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf20kj);

        tf40kj.setBackground(new java.awt.Color(217, 186, 78));
        tf40kj.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf40kj.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf40kj);

        tf60kj.setBackground(new java.awt.Color(217, 186, 78));
        tf60kj.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf60kj.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf60kj);
        getContentPane().add(jLabel8);

        jLabel29.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel29.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel29.setText("monatlich ");
        jLabel29.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        getContentPane().add(jLabel29);

        tf20km.setBackground(new java.awt.Color(217, 186, 78));
        tf20km.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf20km.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf20km);

        tf40km.setBackground(new java.awt.Color(217, 186, 78));
        tf40km.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf40km.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf40km);

        tf60km.setBackground(new java.awt.Color(217, 186, 78));
        tf60km.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf60km.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf60km);
        getContentPane().add(jLabel9);
        getContentPane().add(jLabel10);
        getContentPane().add(jLabel15);
        getContentPane().add(jLabel16);
        getContentPane().add(jLabel17);
        getContentPane().add(jLabel18);

        jLabel19.setBackground(new java.awt.Color(217, 186, 78));
        jLabel19.setFont(new java.awt.Font("NSimSun", 0, 18)); // NOI18N
        jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel19.setText("Großes Pendlerpauschale");
        jLabel19.setOpaque(true);
        getContentPane().add(jLabel19);

        jLabel20.setBackground(new java.awt.Color(217, 186, 78));
        jLabel20.setOpaque(true);
        getContentPane().add(jLabel20);

        jLabel21.setBackground(new java.awt.Color(217, 186, 78));
        jLabel21.setOpaque(true);
        getContentPane().add(jLabel21);

        jLabel22.setBackground(new java.awt.Color(217, 186, 78));
        jLabel22.setOpaque(true);
        getContentPane().add(jLabel22);

        jLabel23.setBackground(new java.awt.Color(217, 186, 78));
        jLabel23.setOpaque(true);
        getContentPane().add(jLabel23);
        getContentPane().add(jLabel24);

        jLabel25.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel25.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel25.setText("ab 2 km");
        getContentPane().add(jLabel25);

        jLabel26.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel26.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel26.setText("über 20 km");
        getContentPane().add(jLabel26);

        jLabel27.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel27.setText("über 40 km");
        getContentPane().add(jLabel27);

        jLabel28.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel28.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel28.setText("über 60 km");
        getContentPane().add(jLabel28);

        jLabel30.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel30.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel30.setText("jährlich ");
        jLabel30.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        getContentPane().add(jLabel30);

        tf2gj.setBackground(new java.awt.Color(217, 186, 78));
        tf2gj.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf2gj.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf2gj);

        tf20gj.setBackground(new java.awt.Color(217, 186, 78));
        tf20gj.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf20gj.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf20gj);

        tf40gj.setBackground(new java.awt.Color(217, 186, 78));
        tf40gj.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf40gj.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf40gj);

        tf60gj.setBackground(new java.awt.Color(217, 186, 78));
        tf60gj.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf60gj.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf60gj);

        jLabel31.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel31.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel31.setText("monatlich ");
        jLabel31.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        getContentPane().add(jLabel31);

        tf2gm.setBackground(new java.awt.Color(217, 186, 78));
        tf2gm.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf2gm.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf2gm);

        tf20gm.setBackground(new java.awt.Color(217, 186, 78));
        tf20gm.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf20gm.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf20gm);

        tf40gm.setBackground(new java.awt.Color(217, 186, 78));
        tf40gm.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf40gm.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf40gm);

        tf60gm.setBackground(new java.awt.Color(217, 186, 78));
        tf60gm.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        tf60gm.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        getContentPane().add(tf60gm);
        getContentPane().add(jLabel32);
        getContentPane().add(jLabel33);
        getContentPane().add(jLabel34);

        btUebernehmen.setBackground(new java.awt.Color(0, 153, 0));
        btUebernehmen.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        btUebernehmen.setForeground(new java.awt.Color(255, 255, 255));
        btUebernehmen.setText("Übernehmen");
        btUebernehmen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btUebernehmenActionPerformed(evt);
            }
        });
        getContentPane().add(btUebernehmen);

        btAbbrechen.setBackground(new java.awt.Color(204, 0, 0));
        btAbbrechen.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        btAbbrechen.setText("Abbrechen");
        btAbbrechen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAbbrechenActionPerformed(evt);
            }
        });
        getContentPane().add(btAbbrechen);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btAbbrechenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAbbrechenActionPerformed
        dispose();
    }//GEN-LAST:event_btAbbrechenActionPerformed

    private void btUebernehmenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btUebernehmenActionPerformed
        try {
            uebernehmen();
            printValues();
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Bitte nur Dezimalzahlen eingeben!");
        }
    }//GEN-LAST:event_btUebernehmenActionPerformed

    private void uebernehmen() throws Exception 
    {
        double[] kppj = new double[3];
        kppj[0] = Double.parseDouble(tf20kj.getText());
        kppj[1] = Double.parseDouble(tf40kj.getText());
        kppj[2] = Double.parseDouble(tf60kj.getText());
        double[] kppm = new double[3];
        kppm[0] = Double.parseDouble(tf20km.getText());
        kppm[1] = Double.parseDouble(tf40km.getText());
        kppm[2] = Double.parseDouble(tf60km.getText());
        data.setKleinesPendlerpauschaleJahr(kppj);
        data.setKleinesPendlerpauschaleMonat(kppm);
        
        double[] gppj = new double[4];
        gppj[0] = Double.parseDouble(tf2gj.getText());
        gppj[1] = Double.parseDouble(tf20gj.getText());
        gppj[2] = Double.parseDouble(tf40gj.getText());
        gppj[3] = Double.parseDouble(tf60gj.getText());
        double[] gppm = new double[4];
        gppm[0] = Double.parseDouble(tf2gm.getText());
        gppm[1] = Double.parseDouble(tf20gm.getText());
        gppm[2] = Double.parseDouble(tf40gm.getText());
        gppj[3] = Double.parseDouble(tf60gj.getText());
        data.setGrossesPendlerpauschaleJahr(gppj);
        data.setGrossesPendlerpauschaleMonat(gppm);
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PendlerpauschaleDLG.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PendlerpauschaleDLG.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PendlerpauschaleDLG.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PendlerpauschaleDLG.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                PendlerpauschaleDLG dialog = new PendlerpauschaleDLG(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAbbrechen;
    private javax.swing.JButton btUebernehmen;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField tf20gj;
    private javax.swing.JTextField tf20gm;
    private javax.swing.JTextField tf20kj;
    private javax.swing.JTextField tf20km;
    private javax.swing.JTextField tf2gj;
    private javax.swing.JTextField tf2gm;
    private javax.swing.JTextField tf40gj;
    private javax.swing.JTextField tf40gm;
    private javax.swing.JTextField tf40kj;
    private javax.swing.JTextField tf40km;
    private javax.swing.JTextField tf60gj;
    private javax.swing.JTextField tf60gm;
    private javax.swing.JTextField tf60kj;
    private javax.swing.JTextField tf60km;
    // End of variables declaration//GEN-END:variables

    
}
